package com.foreknow.demo2;

import com.sun.scenario.effect.impl.prism.ps.PPSRenderer;
import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;

import java.util.Scanner;

/**
 * while循环
 */
public class LoopDemo3 {
    public static void main(String[] args) {
        //商品的名称
        String name = "";
        //商品的价格
        double price = 0;
        //商品的编号
        int goodsNo = 0;

        System.out.println("************************************");
        System.out.println("购物管理系统");
        System.out.println("请选择要购买的商品编号：");
        System.out.println("1.AAAA  2.BBBB  3.CCCC");
        System.out.println("************************************");

        Scanner input = new Scanner(System.in);
        String answer = "y";
        while ("y".equals(answer)) {
        System.out.println("请输入商品的编号");
        goodsNo = input.nextInt();
        switch (goodsNo) {
            case 1:
                name = "AAAA";
                price = 245.0;
                break;
            case 2:
                name = "BBBB";
                price = 165.0;
                break;
            case 3:
                name = "CCCC";
                price = 99.0;
                break;
        }
        System.out.println("商品的名称：" + name + "商品的价格：" + price);
        System.out.println("是否继续添加商品？(y/n)");
        answer = input.next();  // y
        }
        System.out.println("谢谢惠顾！");
    }
}










